<template>
    <div class="login">
        <div class="form-wrapper">
            <div class="header">
                镜像宛陵湖
            </div>
            <!-- <form action="/userManage/login.do" name="form" method="post" onSubmit="return beforeSubmit(this);"> -->
            <div class="input-wrapper">
                <div class="border-wrapper">
                    <input type="text" name="username" id="username" v-model="username" placeholder="用户名"
                        class="border-item" autocomplete="off">
                </div>
                <div class="border-wrapper">
                    <input type="password" name="password" id="password" v-model="password" placeholder="密码"
                        class="border-item" autocomplete="off">
                </div>
            </div>
            <div class="action">
                <!--<input class="btn" type="submit" value="登录"/>-->

                <!--<div class="btn" type="submit">login</div>-->
            </div>
            <!-- </form> -->



            <div class="icon-wrapper">
                <div class="action" @click="gologin">
                    <input class="btn" type="button" value="登录" />
                </div>
            </div>
        </div>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import http from 'axios'
import { ElMessage, ElMessageBox } from 'element-plus'
let username = ref('')
let password = ref('')
let router = useRouter()
let gologin = () => {
    // console.log(username, password);
    if (username.value == '' || password.value == '') {
        ElMessage({
            message: '账号密码不能为空',
            type: 'warning',
        })
        return
    }

    http({
        method: "get",
        url: `/api/user/login`,
        params: {
            username: username.value,
            password: password.value
        },
        baseURL: "api",
    })
        .then((response) => {
            sessionStorage.setItem('login','guxunguo')

            // console.log("登录成功", response);
            router.push({
                path: '/index',

            })
        })
        .catch((error) => {
            console.log("登录失败", error);
        });
}
</script>
<style scoped>
.login {
    width: 100vw;
    height: 100vh;
    background-image: url('../assets/img/1313.png');
    background-repeat: no-repeat;
    background-size: 100VW 100vh;
}

.form-wrapper {
    width: 300px;
    background-color: rgba(41, 45, 62, .8);
    color: #fff;
    border-radius: 2px;
    padding: 50px;
    position: absolute;
    top: 50%;
    left: 50%;
    /* transform: translate(-50% -50%); */
    margin-top: -180px;
    margin-left: -180px;
}

.form-wrapper .header {
    text-align: center;
    font-size: 35px;
    text-transform: uppercase;
    line-height: 100px;
}

.form-wrapper .input-wrapper input {
    background-color: rgb(41, 45, 62);
    border: 0;
    width: 100%;
    text-align: center;
    font-size: 15px;
    color: #fff;
    outline: none;
}

.form-wrapper .input-wrapper input::placeholder {
    text-transform: uppercase;
}

.form-wrapper .input-wrapper .border-wrapper {
    background-image: linear-gradient(to right, #e8198b, #0eb4dd);
    width: 100%;
    height: 50px;
    margin-bottom: 20px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-wrapper .input-wrapper .border-wrapper .border-item {
    height: calc(100% - 4px);
    width: calc(100% - 4px);
    border-radius: 30px;
}

.form-wrapper .action {
    display: flex;
    justify-content: center;
}

.form-wrapper .action .btn {
    width: 60%;
    text-transform: uppercase;
    border: 2px solid #0e92b3;
    text-align: center;
    line-height: 50px;
    border-radius: 30px;
    cursor: pointer;
}

.form-wrapper .action .btn:hover {
    background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
}

.form-wrapper .icon-wrapper {
    text-align: center;
    width: 60%;
    margin: 0 auto;
    margin-top: 20px;
    border-top: 1px dashed rgb(146, 146, 146);
    padding: 20px;
}

.form-wrapper .icon-wrapper i {
    font-size: 20px;
    color: rgb(187, 187, 187);
    cursor: pointer;
    border: 1px solid #fff;
    padding: 5px;
    border-radius: 20px;
}

.form-wrapper .icon-wrapper i:hover {
    background-color: #0e92b3;
}
</style>